home *** CD-ROM | disk | FTP | other *** search
- /*
- File: ASClientAPI.h
-
- Copyright: Copyright Apple Computer, Inc. 1992-1994
- All rights reserved
-
- */
-
- #ifndef __ASCLIENTAPI__
- #define __ASCLIENTAPI__
-
- //______________________________________________________________________________________________________________________
- //______________________________________________________ INCLUDES ______________________________________________________
- //______________________________________________________________________________________________________________________
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __ALIASES__
- #include <Aliases.h>
- #endif
-
-
- //______________________________________________________________________________________________________________________
- //______________________________________________________ CONSTANTS _____________________________________________________
- //______________________________________________________________________________________________________________________
- // errors
-
- #define kNoError 0
-
- //______________________________________________________________________________________________________________________
- // bit-fields
-
- #define kLogon_AutoLogonFlag 0x00000001
- #define kLogon_DeliverUpdateFlag 0x00000002
- #define kLogon_IsGuestFlag 0x00000004
-
- //______________________________________________________________________________________________________________________
- // misc.
-
- enum IDDataType { kProcessSerialNumber, kAEAddressDescriptor, kOther };
-
- #define kMaximumInfoSourceLength 31
- #define kMaximumInfoSources 100
-
- #define kObjType_Reporter 1
- #define kObjType_HitList 2
- #define kObjType_NewspaperDate 3
-
- // #define kObjType_Newspaper 11;
-
- enum ASRequestKind
- {
- kASNullRequest, // [ 0] void request
- kASEnumSourcesRequest, // [ 1] retrieve a list of info sources
- kASGetSourceInfoRequest, // [ 2] open an existing index
- kASOpenSearchRequest, // [ 3] establish a search session
- kASDoSearchRequest, // [ 4] perform a search operation
- kASGetRelatedTermsRequest, // [ 5] expand a search term to a list of related terms
- kASCloseSearchRequest, // [ 6] close a search session
- kASLogoffRequest, // [ 7] retrieve a list of database objects
- kASGetTextRequest, // [ 8] retrieve text of an article
- kASGetMatchesRequest, // [ 9] retrieve match list of an article
- kASGetArticleInfoRequest, // [10] retrieve title and date of an article
- kASGetFileRequest, // [11] retrieve original article file
- kASAddReporterRequest, // [12] add a reporter object
- kASModifyReporterRequest, // [13] modify a reporter object
- kASGetReporterRequest, // [14] retrieve a reporter object
- kASDeleteReporterRequest, // [15] remove a reporter object
- kASEnumReporterRequest, // [16] retrieve a list of reporter objects
- kASImportReporterRequest, // [17] import a reporter object
- kASExportReporterRequest, // [18] export a reporter object
- kASAddObjectRequest, // [19] add a database object
- kASModifyObjectRequest, // [20] modify a database object
- kASGetObjectRequest, // [21] retrieve a database object
- kASDeleteObjectRequest, // [22] remove a database object
- kASEnumObjectRequest // [23] retrieve a list of database objects
- };
-
- //______________________________________________________________________________________________________________________
- //_______________________________________________________ TYPEDEFS _____________________________________________________
- //______________________________________________________________________________________________________________________
-
- typedef long ASErr; // standard error type
- typedef unsigned long int ASLogonSessionID; // ID of the connection to a server
-
- //______________________________________________________________________________________________________________________
- //____________________________ Universal proc pointer definitions ______________________________________________________
- //______________________________________________________________________________________________________________________
-
- // old way
- //typedef long (*ASProcPtr)(char*, long); // proc pointer type for completion
-
- // new way
-
- enum {
- uppASProcInfo = kCStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(long)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(char*)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
- };
-
- #if USESROUTINEDESCRIPTORS
-
- typedef UniversalProcPtr (*ASUPP)(char* thePointer, long theLong);
-
- #define CallASUPP(userRoutine, thePointer, theLong) \
- CallUniversalProc((UniversalProcPtr)(userRoutine), uppASProcInfo, thePointer, theLong)
-
- #define NewASCompletionProc(userRoutine) \
- (ASUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), \
- uppASProcInfo, GetCurrentISA())
-
- #else
-
- typedef ProcPtr (*ASUPP)(char* thePointer, long theLong);
-
- #define NewASCompletionProc(userRoutine) \
- (ASUPP)((userRoutine))
-
- #endif
-
- //______________________________________________________________________________________________________________________
- //___________________________________________________ PARAMETER BLOCKS _________________________________________________
- //______________________________________________________________________________________________________________________
-
- // AppleSearch Client C API param block standard header
-
- #define ASParamBlockHeader \
- long userRefCon; /* for caller's use */ \
- ASErr error; /* API call result */ \
- ASUPP completionProc; /* ptr to a completion routine */ \
- long registrationID; /* from ASRegister */
-
- #if defined(powerc) || defined (__powerc)
- #pragma options align=mac68k
- #endif
-
- struct ASUniversalPB {
- ASParamBlockHeader
- };
- typedef struct ASUniversalPB ASUniversalPB, *ASUniversalPBPtr;
-
- //______________________________________________________________________________________________________________________
-
- struct ASRegisterPB {
- ASParamBlockHeader
- long identifier;
- };
-
- typedef struct ASRegisterPB ASRegisterPB, *ASRegisterPBPtr;
-
- //______________________________________________________________________________________________________________________
-
- struct ASSelectServerPB {
- ASParamBlockHeader
- Ptr defaultServer;
- unsigned long dataSize;
- Ptr dataPtr;
- };
-
- typedef struct ASSelectServerPB ASSelectServerPB, *ASSelectServerPBPtr;
-
- //______________________________________________________________________________________________________________________
-
- struct ASNewLogonPB {
- ASParamBlockHeader
- unsigned long flags;
- char* zoneStr; // null terminated
- char* serverStr; // null terminated
- char* userNameStr; // null terminated
- char* passwordStr; // null terminated
- };
-
- typedef struct ASNewLogonPB ASNewLogonPB, *ASNewLogonPBPtr;
-
-
- //______________________________________________________________________________________________________________________
-
- struct ASLogonPB {
- ASParamBlockHeader
- unsigned long flags; // -> deliverUpdate, autoLogon; <- isGuest
- unsigned long dataSize; // ->
- Ptr dataPtr; // ->
- unsigned long defaultUserNameLength; // ->
- char* defaultUserNameString; // ->
- unsigned long serverNameLength; // <-
- char* serverNameString; // <-
- };
-
- typedef struct ASLogonPB ASLogonPB, *ASLogonPBPtr;
-
- //______________________________________________________________________________________________________________________
-
- struct ASLogoffPB {
- ASParamBlockHeader
- Boolean forceLogoff;
- };
-
- typedef struct ASLogoffPB ASLogoffPB, *ASLogoffPBPtr;
-
- //______________________________________________________________________________________________________________________
-
- struct ASSearchSessionPB {
- ASParamBlockHeader
- long searchSessionID;
- };
-
- typedef struct ASSearchSessionPB ASSearchSessionPB, *ASSearchSessionPBPtr;
-
- //______________________________________________________________________________________________________________________
-
- struct ASDBObjectInfo {
- long dbObjectID;
- // Str31 dbObjectName;
- long dbObjectFlags;
- unsigned long dbObjectNameLength;
- char* dbObjectNameString;
- };
-
- typedef struct ASDBObjectInfo ASDBObjectInfo, *ASDBObjectInfoPtr;
-
-
- struct ASEnumeratePB {
- ASParamBlockHeader
- long dbObjectType; // ->
- unsigned long numberOfDBObjects; // -> number of objects in the list
- ASDBObjectInfoPtr dbObjectList; // -> an array of ASDBObjectInfo structures
- };
-
- typedef struct ASEnumeratePB ASEnumeratePB, *ASEnumeratePBPtr;
-
- //______________________________________________________________________________________________________________________
-
- struct ASHitInfo {
- long articleID;
- long modDate;
- unsigned long fileSize;
- unsigned long rank;
- unsigned long titleLength;
- char* titleString;
- };
-
- typedef struct ASHitInfo ASHitInfo, *ASHitInfoPtr;
-
-
- struct ASSearchPB {
- ASParamBlockHeader
- long searchSessionID;
- long sourceID;
- unsigned long queryLength;
- char* queryString; // c string, null terminated
- unsigned long minimumRank;
- unsigned long maximumHits; // NOTE: who allocates the memory for hits?
- long earliestModDate;
- long searchType;
- long searchID;
- unsigned long numberOfHitsReturned;
- unsigned long totalNumberOfHits;
- ASHitInfoPtr* hitList; // packed array of ASHitPtrs
- };
-
- typedef struct ASSearchPB ASSearchPB, *ASSearchPBPtr;
-
- //______________________________________________________________________________________________________________________
-
- struct ASGetArticleInfoPB {
- ASParamBlockHeader
- long sourceID; // <-
- long articleID; // <-
- long modDate; // ->
- unsigned long size; // ->
- unsigned long titleLength; // ->
- char* titleString; // ->
- };
-
- typedef struct ASGetArticleInfoPB ASGetArticleInfoPB, *ASGetArticleInfoPBPtr;
-
- //______________________________________________________________________________________________________________________
-
- struct ASGetArticleTextPB {
- ASParamBlockHeader
- long searchSessionID;
- long sourceID;
- long articleID;
- unsigned long startOffset;
- unsigned long length;
- Handle text;
- };
-
- typedef struct ASGetArticleTextPB ASGetArticleTextPB, *ASGetArticleTextPBPtr;
-
- //______________________________________________________________________________________________________________________
-
- struct ASGetArticleMatchesPB {
- ASParamBlockHeader
- long searchSessionID;
- long sourceID;
- long articleID;
- unsigned long startOffset;
- unsigned long length;
- unsigned long numberOfHiliteInfoRecs;
- long* hiliteInfo; // points to the first long of array of hiliteinfoRecs
- };
-
- typedef struct ASGetArticleMatchesPB ASGetArticleMatchesPB, *ASGetArticleMatchesPBPtr;
-
- //______________________________________________________________________________________________________________________
-
- struct ASHiliteInfoRec {
- unsigned long offset;
- unsigned long length;
- };
-
- typedef struct ASHiliteInfoRec ASHiliteInfoRec, *ASHiliteInfoRecPtr;
-
- //______________________________________________________________________________________________________________________
-
- struct ASGetOriginalFilePB {
- ASParamBlockHeader
- long sourceID;
- long articleID;
- long flags; // 1 = origional file; 2 = alias to file
- FSSpec fileDestination;
- AliasHandle alias;
- };
-
- typedef struct ASGetOriginalFilePB ASGetOriginalFilePB, *ASGetOriginalFilePBPtr;
-
- //______________________________________________________________________________________________________________________
-
- struct ASReporterPB {
- ASParamBlockHeader
- long reporterID; //
- unsigned long nameLength; //
- char* nameString; //
-
- // search parameters
- unsigned long queryLength; //
- char* queryString; // c string, null terminated
- unsigned long minimumRank; //
- unsigned long maximumHits; //
- long earliestModDate; //
- long earliestIndexDate; //
- unsigned long numberOfSources; //
- long* sourceList; //
-
- // scheduling info
- unsigned long deliveryDays; //
- unsigned long deliveryTime; //
- long deliveryFlags; //
- unsigned long deliveryDirLength; //
- AliasPtr deliveryDir; //
- };
-
- typedef struct ASReporterPB ASReporterPB, *ASReporterPBPtr;
-
- //______________________________________________________________________________________________________________________
-
- struct ASDBObjectPB {
- ASParamBlockHeader
- long dbObjectType;
- ASDBObjectInfo dbObjectInfo;
- long sourceID; // used only if type is hit list
- unsigned long dbObjectDataSize;
- Ptr dbObjectData;
- };
-
- typedef struct ASDBObjectPB ASDBObjectPB, *ASDBObjectPBPtr;
-
- //______________________________________________________________________________________________________________________
-
- struct ASImportExportPB {
- ASParamBlockHeader
- FSSpec reporterFile; //
- long reporterID; //
- unsigned long nameLength;
- char* nameString;
- };
-
- typedef struct ASImportExportPB ASImportExportPB, *ASImportExportPBPtr;
-
- //______________________________________________________________________________________________________________________
-
- struct ASGetRelatedTermsPB {
- ASParamBlockHeader
- long sourceID; // <-
- unsigned long queryLength; // <-
- char* queryString; // <-
- unsigned long maximumTerms; // <-
- unsigned long numberOfTerms; // ->
- StringPtr* termList; // ->
- };
-
- typedef struct ASGetRelatedTermsPB ASGetRelatedTermsPB, *ASGetRelatedTermsPBPtr;
-
- //______________________________________________________________________________________________________________________
-
- struct ASGetSourceInfoPB {
- ASParamBlockHeader
- long sourceID; // <-
- unsigned long numberOfDocsIndexed; // ->
- unsigned long indexFileSize; // ->
- unsigned long textSizeIndexed; // ->
- unsigned long lastIndexedDate; // ->
- Str255 description; // ->
- };
-
- typedef struct ASGetSourceInfoPB ASGetSourceInfoPB, *ASGetSourceInfoPBPtr;
-
- #if defined(powerc) || defined(__powerc)
- #pragma options align=reset
- #endif
-
- //______________________________________________________________________________________________________________________
- //_________________________________________________ FUNCTION PROTOTYPES ________________________________________________
- //______________________________________________________________________________________________________________________
-
- //______________________________________________________________________________________________________________________
- // "House keeping" routines
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- extern void ASInitialize( void ); // must be called to initialize internal globals
- extern void ASQuit( void ); // call it when your application is ready to quit
- extern ASErr ASDoIdle( void ); // must be called in each waitNexEvent loop
- extern ASErr ASRegister( ASRegisterPBPtr pb );
- extern ASErr ASUnregister( ASRegisterPBPtr pb );
- extern ASErr ASSelectServer( ASSelectServerPBPtr pb );
- extern ASErr ASLogon( ASLogonPBPtr pb );
- extern ASErr ASNewLogon( ASNewLogonPBPtr pb ); // may not work in later versions of the system! NOT supported
- // it is here for your convenience only. It was only tested
- // with system 7.5 and earlier
- extern ASErr ASLogoff( ASLogoffPBPtr pb );
-
- //______________________________________________________________________________________________________________________
- // Search routines
-
- extern ASErr ASOpenSearchSession( ASSearchSessionPBPtr pb, Boolean async );
- extern ASErr ASCloseSearchSession( ASSearchSessionPBPtr pb, Boolean async );
- extern ASErr ASSearch( ASSearchPBPtr pb, Boolean asynch );
-
- //______________________________________________________________________________________________________________________
- // Data retrieval routines
-
- extern ASErr ASEnumerateSources( ASEnumeratePBPtr pb, Boolean async );
- extern ASErr ASGetArticleText( ASGetArticleTextPBPtr pb, Boolean asynch );
- extern ASErr ASGetArticleMatches( ASGetArticleMatchesPBPtr pb, Boolean asynch );
- extern ASErr ASGetArticleInfo( ASGetArticleInfoPBPtr pb, Boolean async );
- extern ASErr ASGetOriginalFile( ASGetOriginalFilePBPtr pb, Boolean asynch );
- extern ASErr ASGetRelatedTerms( ASGetRelatedTermsPBPtr pb, Boolean async );
-
- //______________________________________________________________________________________________________________________
- // Reporter routines
-
- extern ASErr ASAddReporter( ASReporterPBPtr pb, Boolean async );
- extern ASErr ASModifyReporter( ASReporterPBPtr pb, Boolean async );
- extern ASErr ASGetReporter( ASReporterPBPtr pb, Boolean async );
- extern ASErr ASDeleteReporter( ASReporterPBPtr pb, Boolean async );
- extern ASErr ASEnumerateReporters( ASEnumeratePBPtr pb, Boolean async );
-
- extern ASErr ASImportReporter( ASImportExportPBPtr pb, Boolean async );
- extern ASErr ASExportReporter( ASImportExportPBPtr pb, Boolean async );
-
- //______________________________________________________________________________________________________________________
- // DBObject routines
-
- extern ASErr ASAddDBObject( ASDBObjectPBPtr pb, Boolean async );
- extern ASErr ASModifyDBObject( ASDBObjectPBPtr pb, Boolean async );
- extern ASErr ASGetDBObject( ASDBObjectPBPtr pb, Boolean async );
- extern ASErr ASDeleteDBObject( ASDBObjectPBPtr pb, Boolean async );
- extern ASErr ASEnumerateDBObjects( ASEnumeratePBPtr pb, Boolean async );
-
- //______________________________________________________________________________________________________________________
- //__________________________________________________ UTILITY FUNCTIONS _________________________________________________
- //______________________________________________________________________________________________________________________
- // Bogart <-> standard Mac time conversion routines
-
- typedef long NewDateTimeCode;
-
- extern pascal NewDateTimeCode MacToNewDateTime(unsigned long theMacTime);
- extern pascal unsigned long NewDateTimeToMacTime(NewDateTimeCode theNewDateTime);
-
- //______________________________________________________________________________________________________________________
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif // __ASCLIENTAPI__
-
-